#ifndef LOGINMODULE_H
#define LOGINMODULE_H

#include "ModuleInterface.h"
#include "registerLoginMessage.pb.h"
#include "utils/eccoperator.h"
#include "utils/symmetricencryption.h"
using namespace videoMettingServer;

typedef struct loginResonpseResult
{
    ResponseStatus status;
    QString response_result;
} loginResonpseResult;

class loginModule : public ModuleInterface
{
public:
    loginModule();
    ~loginModule() override = default;
    bool initialize() override;
    QByteArray execute() override;
    bool handleReceiveData(const QByteArray &receiveData) override;
    void setPhoneNumberPasswd(const QString &phoneNumber, const QString &passwd);
    loginResonpseResult getResponseResult();
    bool getIsInitalized();

private:
    std::vector<unsigned char> computeSessionKey(BIGNUM *clientPriKey,
                                                 EC_POINT *peerPubKey,
                                                 unsigned char *salt);
    std::string constructLoginRequestMessage();
    std::string constructSafeLoginRequestMessage(const std::string &data);

private:
    std::string clientCert_PEM;
    ECCOperator m_ecc;
    std::vector<unsigned char> sessionKey_vector;
    QString m_phoneNumber;
    QString m_passwd;
    SymmetricEncryption m_symm;
    loginResonpseResult response_result;
    bool isInitalized;
};

#endif // LOGINMODULE_H
